<?php
    if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();
    
    //if they give an api token, try using it.
    if($_REQUEST['api'])
        session_id($_REQUEST['api']);
    
	require('jacked_configVars.php');
	require('jacked_functions.php');
	require('jacked_configapilol.php');
	
    global $APIresult, $method;    

    //REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API REST API 


    function api_error($reason, $lol){
        global $APIresult;
        $APIresult = array("done" => "NOEP", "reason" => $reason, "lolReason" => $lol);
        return true;
    }
        
    function api_done($data){
        global $APIresult;
        $APIresult = array("done" => "success", "data" => $data);
        return true;
    }
    
    function api_useGET(){
        global $APIresult, $method;

        include_once('jacked_apilolfunctions.php');
        api_call('GET');
        
    }
    
    function api_usePOST(){
        global $APIresult, $method;
		include_once('jacked_managepdnet_api.php');
		
        include_once('jacked_apilolfunctions.php');
        api_call('POST');
        
    }
    
    function printDebug($var){
        echo '<pre><code>';
        print_r($var);
        echo '</code></pre>';
    }


    $method = $_SERVER['REQUEST_METHOD'];
    
    switch ($method) {
        case 'PUT':
        api_error("PUT Method not accepted.", "Yeah, it's a REST method, but I don't use it, so who gives a shit?");  
        break;
      case 'POST':
        api_usePOST();
        
        break;
      case 'GET':
        api_useGET();

        break;
      case 'HEAD':
        api_error("HEAD Method not accepted.", "Seriously, I will not give you HEAD so stop asking.");  
        break;
      case 'DELETE':
        api_error("DELETE Method not accepted.", "Like I'm really gonna let you use that on my server. You fucking queer.");  
        break;
      case 'OPTIONS':
        api_error("OPTIONS Method not accepted.", "I don't even know what the fuck this is, so why do you?");
        break;
      default:
        api_error("Invalid REST method.", "I have no idea what you used to get to this page, but whatever it is, it's wrong.");
        break;
    }
    
    
    
    //THIS ENTIRE PAGE IS A SINGLE ECHO??? WHAT THE FUCK IS THAT?!?
    ////man, i could fucking write this api, that shit is easy. 

    echo json_encode($APIresult);







//wait, no i did write this api though. i'm confused
?>